package day02;

import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

public class Test {
    public static void main(String[] args) {
        xx(() -> UUID.randomUUID().toString());

        x1(a -> System.out.println(a), 88);

        x2(s->s!=null?s.length():0,"hello");

        x3(s->s.length()>5, "jjjjjjj", s->s.length()<10);
    }



    //Predicate  接收一个泛型数据，返回一个bool值，判断这个泛型数据是否满足某种条件
    public static void x3(Predicate<String> predicate,String s,Predicate<String> predicate1){
        boolean test = predicate.test(s);
        boolean test1 = predicate1.test(s);
        System.out.println(test);

        predicate.and(predicate1).test(s);
        predicate.or(predicate1).test(s);
        predicate.negate().test(s);
    }

    //Function  接收泛型数据，然后返回一个泛型数据
    public static void x2(Function<String,Integer> function,String s){
        Integer apply = function.apply(s);
        System.out.println(apply);
    }

    //Consumer  接收一个泛型数据
    public static void x1(Consumer consumer, Integer integer) {
        consumer.accept(integer);
    }

    //Supplier   返回一个泛型数据
    public static void xx(Supplier<String> supplier) {
        String s = supplier.get();
        System.out.println(s);
    }
}
